home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / borland / jnfb88.zip / KEYINT.ZIP / NOREBOOT.PAS < prev    next >
Pascal/Delphi Source File  |  1987-10-08  |  3KB  |  97 lines

  1. PROGRAM No_Reboot;
  2. {=============}
  3. {BEGIN INCLUDE}
  4. {=============}
  5. Uses Crt, Dos;
  6. CONST
  7.   D_Key = 83; (* SCAN code of the Del key *)
  8.   Kbd_Int = 9;
  9.  
  10. VAR
  11.   Kbd_Vec, Exit_Vec : Pointer;
  12.  
  13. {$I ERROR.INC}
  14.  
  15.   PROCEDURE INT9_ISR(_Flags, _CS, _IP, _AX, _BX, _CX, _DX,
  16.                              _SI, _DI, _DS, _ES, _BP:word);
  17.   INTERRUPT;
  18.   (* ======================================== *)
  19.   (* This routine suppresses the <Del> key.   *)
  20.   (* If it detects either a "make" or a       *)
  21.   (* "break" from the <Del> key, it simply    *)
  22.   (* resets the keyboard.  Without <Del>      *)
  23.   (* there's no way to enter <Ctrl><Alt><Del> *)
  24.   (* so you can't reboot.                     *)
  25.   (* ======================================== *)
  26.   BEGIN
  27.     INLINE(
  28.     $FB/              {STI            ;Allow interrupts}
  29.     $9C/              {PUSHF          ;Save the flags}
  30.     $E4/$60/          {IN   AL,$60    ;READ the keyboard port}
  31.     $24/$7F/          {AND  AL,$7F    ;Mask off "break bit"}
  32.     $3C/<D_KEY/       {CMP  AL,<D_KEY ;Is it a "Del" key?}
  33.     $74/$18/          {JZ   GetOut    ;If so, throw it away}
  34.     (* ============================ *)
  35.     (* CHAIN to the regular INT 9   *)
  36.     (* ============================ *)
  37.     $9D/              {POPF         ;Restore the flags}
  38.     $A1/>KBD_VEC+2/   {MOV  AX,[>KBD_VEC+2] ;Old vector seg to AX}
  39.     $8B/$1E/>KBD_VEC/ {MOV  BX,[>KBD_VEC]   ;Old vector ofs to BX}
  40.     $87/$5E/$0E/      {XCHG BX,[BP+$0E] ;Swap ofs w/ return address}
  41.     $87/$46/$10/      {XCHG AX,[BP+$10] ;Swap seg w/ return address}
  42.     $89/$EC/          {MOV  SP,BP ;UNDO procedure's entry code}
  43.     $5D/              {POP  BP}
  44.     $07/              {POP  ES}
  45.     $1F/              {POP  DS}
  46.     $5F/              {POP  DI}
  47.     $5E/              {POP  SI}
  48.     $5A/              {POP  DX}
  49.     $59/              {POP  CX}
  50.     $CB/              {RETF ;in effect, JMP to old vector}
  51. {GetOut:}
  52.     $E4/$61/          {IN   AL,$61  ;Read Kbd controller port}
  53.     $88/$C4/          {MOV  AH,AL}
  54.     $0C/$80/          {OR   AL,$80  ;Set the "reset" bit and}
  55.     $E6/$61/          {OUT  $61,AL  ;  send it back to control}
  56.     $86/$C4/          {XCHG AH,AL   ;Get back control value}
  57.     $E6/$61/          {OUT  $61,AL  ;  and send it too}
  58.     $9D/              {POPF         ;Restore the flags}
  59.     $FA/              {CLI          ;No interrupts }
  60.     $B0/$20/          {MOV  AL,+$20 ;Send an EOI to the}
  61.     $E6/$20);         {OUT  $20,AL  ;  interrupt controller }
  62.   END;
  63.  
  64. {=============}
  65. {END INCLUDE  }
  66. {=============}
  67.  
  68.   PROCEDURE Do_Demo;
  69.   VAR
  70.     L : STRING[80];
  71.   BEGIN
  72.     ClrScr;
  73.     WriteLn('KEYBOARD INTERRUPT DEMO "REBOOT PROHIBITED"');
  74.     WriteLn('===========================================');
  75.     WriteLn;
  76.     Write('IF SideKick is not loaded, you ');
  77.     WriteLn('cannot reboot from within');
  78.     Write('this program.  Try it!  You can ');
  79.     WriteLn('enter text, but you cannot');
  80.     WriteLn('reboot.  Enter a blank line to quit.');
  81.     WriteLn;
  82.     REPEAT
  83.       ReadLn(L);
  84.       WriteLn(L);
  85.     UNTIL L = '';
  86.   END;
  87.  
  88. BEGIN
  89.   CheckBreak := TRUE;
  90.   GetIntVec(Kbd_Int, Kbd_Vec);   {save "old" INT9}
  91.   SetIntVec(Kbd_Int, @INT9_ISR); {install new}
  92.   Exit_Vec := ExitProc;          {save old ExitProc}
  93.   ExitProc := @My_Error;         {install new}
  94.   Do_Demo;                       {show yer stuff!}
  95.   {Interrupt vector is RESTORED in the ExitProc}
  96. END.
  97.